<!DOCtype html>
<html ng-app="advertiserApp">
<head>
    <meta charset="utf-8"/>
    <title>基本信息1</title>
    <script type="text/javascript" src="/web-adv/advWeb/static/vendor/angular/angular.min.js"></script>
    <script type="text/javascript" src="/web-adv/advWeb/static/vendor/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="/web-adv/advWeb/static/vendor/bootstrap/dist/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/web-adv/advWeb/static/js/mainApp.js"></script>
    <script type="text/javascript" src="/web-adv/advWeb/controller/advertiserCtrl.js"></script>
    <script type="text/javascript" src="/web-adv/advWeb/static/js/main.js"></script>
    <script type="text/javascript" src="/web-adv/advWeb/controller/userCenter/basicInfo/index.js"></script>
	<script type="text/javascript" src="/web-adv/advWeb/static/js/ajaxupload.js"></script>
    <link rel="stylesheet" href="/web-adv/advWeb/static/vendor/bootstrap/dist/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/web-adv/advWeb/static/vendor/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css"/>
    <link rel="stylesheet" href="/web-adv/advWeb/static/styles/layout.css"/>
    <link rel="stylesheet" href="/web-adv/advWeb/static/styles/main.css"/>
    <link rel="shortcut icon" href="/web-adv/advWeb/static/favicon.ico"/>
    <link rel="bookmark" href="/web-adv/advWeb/static/favicon.ico"/>
    <style>
    .content .itemEditForm .form-group .basicinfoinput{width:505px;display:none}  
    .content .add{color:#d7000f;line-height:34px;}
	.uploadImgBox img{display:block;width:300px;height:170px;background:url('/web-adv/advWeb/static/images/uploadBg.png');background-size:cover;}
	.uploadBtnBox{margin-top:20px;position:relative;width:300px;height:42px;z-index:100;}
	.uploadBtnBox .uploadBtn{cursor:pointer;top:0px;left:0px;width:100%;height:100%;z-index:1000;position:absolute;opacity:0;}
	.uploadBtnBox button{cursor:pointer;background:#478DF1;border:none;width:100%;height:100%;padding:0px;line-height:42px;}
	#comfirmUpdate{background-color:#478df1;margin-left:809px;}
	.content .itemEditForm .form-group .rightAlign{width:570px;}
	.basicinfoinputShow{line-height:41px;height:41px;font-size:16px;display:inline-block}
	.repeatAlert{color:#d7000f;}
    </style>    
</head>
<body ng-controller="advertiserCtrl">
<div class="headerBox"></div>
<div class="nav">
    <ul></ul>
</div>
<div class="content container" id="basicInfohtml">
    <!-- begin -->
    <div class="websiteMapBox">
        <span>当前页面></span>
        <span>基本信息</span>
    </div>
    <div class="itemEditForm">
        <p class="title returnBtn">
            <span>基本信息</span>
            <button class="btn btn-primary right" id="updateBasicInfo">修改</button>
            <button class="right btn btn-primary" id="returnBtn" >返回</button>
        </p>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>公司名称：</label>
            <input type="hidden" id="flag" value=""/>
            <input type="text" class="left form-control  basicinfoinput" id="companyName" maxlength="30"/>
            <p class="basicinfoinputShow"></p>
            <div class="clear"></div>
        </div>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>小毛驴会员昵称：</label>
            <input type="text" class="left form-control  basicinfoinput" id="memberName"/><span class="repeatAlert"></span>
            <p class="basicinfoinputShow"></p>
            <span id="userNamePat" class="add"></span>
            <span id="memberNamePat" class="add"></span>
            <div class="clear"></div>
        </div>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>小毛驴账号：</label>
            <input type="text" class="left form-control  basicinfoinput" id="donkeyNum"  disabled="disabled"/>
            <p class="basicinfoinputShow"></p>
            <div class="clear"></div>
        </div>
        <!-- <div class="form-group form-inline">
            <label class="left rightAlign">信用级别：</label>
            <input type="text" class="left form-control form-controlNo basicinfoinput" id="creditRat"/>
            <div class="clear"></div>
        </div> -->
        <div class="clear"></div>
    </div>
    <div class="itemEditForm">
        <p class="title">
            <span>公司通讯资料</span>
        </p>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>公司地址：</label>
            <input type="text" class="left form-control  basicinfoinput" id="companyAddress" maxlength="30"/>
            <p class="basicinfoinputShow"></p>
            <div class="clear"></div>
        </div>
        <!-- <div class="form-group form-inline">
            <label class="left rightAlign">固定电话：</label>
            <input type="text" class="left form-control form-controlNo basicinfoinput" readonly="readonly" value="010-11211122" id="fixedPhone"/>
            <div class="clear"></div>
        </div> -->
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>E-mail：</label>
            <input type="text" class="left form-control  basicinfoinput" id="email" disabled="disabled"/>
                   <!-- 存放原来的email -->
              <input type="hidden" id="oldEmail">   
            <p class="basicinfoinputShow"></p>    
            <span id="emailPat" class="add">*请输入正确邮箱格式</span>
            <div class="clear"></div>
        </div>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>公司网址：</label>
            <input type="text" class="left form-control  basicinfoinput" id="websiteUrl"/>
            <p class="basicinfoinputShow"></p>
            <!-- <span id="webUrlPat" class="add">*请输入正确网址</span> -->
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="itemEditForm">
        <p class="title">
            <span>公司管理员信息</span>
        </p>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>姓名：</label>
            <input type="text" class="left form-control basicinfoinput" id="realName"/>
            <p class="basicinfoinputShow"></p>
            <div class="clear"></div>
        </div>
      
        <div class="form-group form-inline">
            <label class="left rightAlign">固定电话：</label>
            <input type="text" class="left form-control basicinfoinput" id="FixedPhone"/>
            <p class="basicinfoinputShow"></p>
            <span id="phonePat" class="add">*请按&nbsp010-88888888&nbsp格式输入</span>
            <div class="clear"></div>
        </div>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>手机：</label>
            <input type="text" class="left form-control  basicinfoinput" id="mobilePhone"/>
            <p class="basicinfoinputShow"></p>
            <span id="mobilePat" class="add">*请正确输入手机号</span>
            <div class="clear"></div>
        </div>
        <div class="form-group form-inline">
            <label class="left rightAlign">邮箱：</label>
            <input type="text" class="left form-control  basicinfoinput" id="adminemail"/>
            <p class="basicinfoinputShow"></p>
            <span id="mailboxPat" class="add">*请正确输入邮箱</span>
            <div class="clear"></div>
        </div>
        <div class="form-group form-inline">
            <label class="left rightAlign">QQ：</label>
            <input type="text" class="left form-control basicinfoinput" id="qq"/>
            <p class="basicinfoinputShow"></p>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="itemEditForm">
        <p class="title">
            <span>银行账号</span>
        </p>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>开户名：</label>
            <input type="text" class="left form-control basicinfoinput" id="bankName"/>
            <p class="basicinfoinputShow"></p>
            <div class="clear"></div>
        </div>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>开户行：</label>
            <input type="text" class="left form-control basicinfoinput" id="openBank"/>
            <p class="basicinfoinputShow"></p>
            <div class="clear"></div>
        </div>
        <div class="form-group form-inline">
            <label class="left rightAlign"><span style='color:#d7000f' class="star">*</span>开户账号：</label>
            <input type="text" class="left form-control  basicinfoinput" id="accountNumbe"/>
            <p class="basicinfoinputShow"></p>
            <span id="accountPat" class="add">*请输入正确开户账号</span>
            <div class="clear"></div>
        </div>
    </div>
    <div class="itemEditForm lastItemEditForm">
        <p class="title">
            <span>广告主logo</span>
        </p>
        <div class="form-group form-inline">
            <label class="left rightAlign leftTitle"><span style='color:#d7000f' class="star">*</span>上传广告主logo：</label>
            <input id="logo_url" type="hidden" name="companyLogo"/>
            <div class="left uploadBox">			                   
                <div class="uploadImgBox uploadImgBoxLogo">
                    <img src="" alt="" id="logo_img"/>
                </div>
                <label class="hide" style="text-align:center;padding-top:18px;">（图片支持jpg、png   大小2k-2M）</label>
				<div class="uploadBtnBox hide">
				     <input type="file" class="left uploadBtn" id="upload_logo"/>
				     <button class="btn btn-primary" id="btnOne">上传广告主logo</button>
				</div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="itemEditForm lastItemEditForm">
        <p class="title">
            <span>上传营业执照</span>
        </p>
        <div class="form-group form-inline">
            <label class="left rightAlign leftTitle"><span style='color:#d7000f' class="star">*</span>上传营业执照：</label>
            <input id="buss_url" type="hidden" name="businessLicence"/>
            <div class="left uploadBox">			                  
                <div class="uploadImgBox">
                    <img src="" alt="" id="buss_img"/>
                </div>
                <label class="hide" style="text-align:center;padding-top:18px;">（图片支持jpg、png   大小2k-2M）</label>
				<div class="uploadBtnBox hide">
				     <input type="file" class="left uploadBtn" id="upload_business_license"/>
				     <button class="btn btn-primary" id="btnTwo">上传营业执照</button>
				</div> 
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="itemEditForm lastItemEditForm">
        <p class="title">
            <span>上传组织机构代码</span>
        </p>
        <div class="form-group form-inline">
            <label class="left rightAlign leftTitle"><span style='color:#d7000f' class="star">*</span>上传组织机构代码：</label>
            <input id="org_url" type="hidden" name="organizationCode"/>
            <div class="left uploadBox">			                   
                <div class="uploadImgBox uploadImgBoxCode">
                    <img src="" alt="" id="org_img"/>
                </div>
                <label class="hide" style="text-align:center;padding-top:18px;">（图片支持jpg、png   大小2k-2M）</label>
				<div class="uploadBtnBox hide">
				     <input type="file" class="left uploadBtn" id="upload_organization"/>
				     <button class="btn btn-primary" id="btnThree">上传组织机构代码</button>
				</div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    
    <div class="form-group form-inline" >
        <label class="left rightAlign"></label>
        <div class="btnGroup hide">
            <button class="left btn btn-primary" id="comfirmUpdate">确认提交</button>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
</div>
<!-- end -->
</body>
</html>
<script type="text/javascript">
    //修改/展示状态切换
    var tabEditShow = function () {
        //进入编辑状态
        var _this = this;
        _this.edit = function () {
            $(".itemEditForm").find(".title").children(".btn").click(function () {
            	
            	$("#returnBtn").show();
            	
            	$(".btnGroup").removeClass("hide");//确认提交按钮显示
            	$(".uploadBtnBox").toggleClass("hide show");
            	$(".uploadBox label").toggleClass("hide show");           	
                $(this).parents(".content").children(".itemEditForm").find(".form-group").each(function () {
                    //$(this).find('[type="text"]').removeClass("form-controlNo").attr("disabled", false);
                    $(this).find('[type="text"]').show();
                    $(this).find(".basicinfoinputShow").hide();
                    $(".star").show();
                });
                $(this).addClass("hide");
                $(this).parents(".itemEditForm").siblings(".lastItemEditForm").find(".btnGroup").toggleClass("show hide");
            });
        };
        //进入展示状态
        _this.show = function () {
            $("#comfirmUpdate").click(function () {
                $(this).parents(".content").children(".itemEditForm").find(".form-group").each(function () {
                    $(this).find('[type="text"]').addClass("form-controlNo").attr("disabled", true);
                });
                $(this).parent().toggleClass("hide show");
                $(this).parents(".lastItemEditForm").siblings(".itemEditForm").first().children(".title").find(".btn").toggleClass("show hide");
                $(".uploadBtnBox").toggleClass("show hide");
            	$(".uploadBox label").toggleClass("show hide");   
                var companyName= $('#companyName').val();
        		var memberName=$('#memberName').val();
        
        		var donkeyNum=$('#donkeyNum').val();
        		//var creditRating=$('#creditRat').val();
        		var companyAddress=$('#companyAddress').val();
        		var email=$('#email').val();
        		var oldEmail=$('#oldEmail').val();
        		var websiteUrl=$('#websiteUrl').val();
        		var realName=$('#realName').val();
        		var fixedPhone=$('#FixedPhone').val();
        		var mobilePhone=$('#mobilePhone').val();
        		var adminMail=$('#adminemail').val();
        		var bankName=$('#bankName').val();
        		var openBank=$('#openBank').val();
        		var accountNumber=$('#accountNumbe').val();
        		var qq=$('#qq').val();
        		var id = $('#flag').val();
        		
                
        		//上传
        		var companyLogo=$("#logo_url").val();
        		var businessLicence=$("#buss_url").val();
        		var organizationCode=$("#org_url").val();
        		
                var loginReturnBean = {
                    companyName: companyName,               
                    memberName: memberName,
                    donkeyNum:donkeyNum,
                    companyAddress: companyAddress,                  
                    email: email,
                    websiteUrl: websiteUrl,
                    realName: realName,
                    fixedPhone: fixedPhone,
                    mobilePhone: mobilePhone,
                    adminMail: adminMail,
                    bankName: bankName,
                    openBank: openBank,
                    accountNumber: accountNumber,
                    qq:qq,
                    advId: id,
                   
                    //上传图片
                    companyLogo:companyLogo,
                    businessLicence:businessLicence,
                    organizationCode:organizationCode
                };
                
	    		var path=escape('selectedNav=0&navPos=0');
	    		if(email==oldEmail){    	//判断邮箱是否更改
	    			var nowName=$('#memberName').val();
	    			  $.ajax({
                      	 url: '/web-adv/checkMemberName',
                      	 data:{nowName:nowName},
                      	 type:'post',
                      	 success:function(data){
                      		console.log(data);
                     		    if(data.status == "-1"){
                     		    	//显示提示（昵称已存在）
                     		    	$(".itemEditForm").find(".form-group input").removeClass("form-controlNo").attr("disabled",false);
                     		    	$(".repeatAlert").html(data.error);
                     		    }else{
                     		    	//验证通过
                     		       $.ajax({
                                       url: '/web-adv/updateBasicInfo',
                                       data: loginReturnBean,
                                       type: 'post',
                                       success: function (data) {
                                          	if (data.status == -1) {
                                           	 $("#memberNamePat").html(data.error);
                                           	 $(".itemEditForm").find(".form-group input").removeClass("form-controlNo").attr("disabled",false);
                                          	} else {
                                          	window.location.href = "/web-adv/advWeb/views/userCenter/basicInfo/saveSuccess.html?"+path;
                                          	 }
                                         	},                    
                                      	});
                     		    }
                      	 },
                      	error: function (xhr) {
                            console.log("readyState" + xhr.readyState + "status" + xhr.status);
                        }
                      });
             
	    	  }else{
	    		  if(confirm("此页面无法修改邮箱，是否前往[账户安全]中修改邮箱?")){
	    			  path=escape('selectedNav=0&navPos=4');
	    			  window.location.href = "/web-adv/advWeb/views/userCenter/accountSecurity/index.html?"+path;
	    		  }else{
	    			  $('#email').val(oldEmail);
	    			  $(".itemEditForm").find(".form-group input").removeClass("form-controlNo").attr("disabled",false);
	    		  }
	    	  }
         });
            $("#returnBtn").click(function () {
            
               window.location.href="/web-adv/advWeb/views/userCenter/basicInfo/index.html?selectedNav=0&navPos=0";
                $(this).parents(".content").children(".itemEditForm").find(".form-group").each(function () {
                    $(this).find('[type="text"]').addClass("form-controlNo").attr("disabled", true);
                });
                $(this).parent().toggleClass("hide show");
                $(this).parents(".lastItemEditForm").siblings(".itemEditForm").first().children(".title").find(".btn").toggleClass("show hide");
                
            });
        };
        _this.init = function () {
            _this.edit();
            _this.show();
        }
    }
    var tabEditShowObj = new tabEditShow();
    tabEditShowObj.init();
</script>
